# estimate parameters of Thomas point process model
# 
# Author: guochun
###############################################################################


agModeling.thomasM=function(modelingObject){
	fittedModel=inhomK(modelingObject)
	rethomas=thomas.estK(attr(fittedModel,"K"),c(kappa=10, sigma2=0.1),
			rmax=attr(fittedModel,"rmax"))
	pnames=names(rethomas$par)
	p1=new("parameter",name=pnames[1],value=as.numeric(rethomas$par[1]))
	p2=new("parameter",name=pnames[2],value=as.numeric(rethomas$par[2]))
	prenames=names(fittedModel@parameters)
	fittedModel@parameters=c(fittedModel@parameters,p1,p2)
	names(fittedModel@parameters)=c(prenames,pnames)
	
	if(modelingObject@pvalue){
		fittedModel=confi.inter(fittedModel,p1@value,sqrt(p2@value))		
	}
	return(fittedModel)
}
